/**
 * Project Name:SL_Store
 * File Name:SetCharUtil.java
 * Package Name:util
 * Date:2018楠烇拷閺堬拷閺冦儰绗呴崡锟�15:33
 * Copyright (c) 2018, bluemobi All Rights Reserved.
 */

package util;

import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import javax.servlet.http.HttpSession;
import com.jspsmart.upload.Request;


/**
 * Description:   <br/>
 * Date:     2018楠烇拷閺堬拷閺冿拷娑撳宕�:15:33 <br/>
 * @author   LiuPeng
 * @version
 * @see
 */
public class SetCharUtil implements Filter {

    public void destroy() {

        // Auto-generated method stub

    }

    public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2) throws IOException,
            ServletException {

        // Auto-generated method stub
        HttpServletRequest request = (HttpServletRequest) arg0;
        HttpServletResponse response = (HttpServletResponse) arg1;
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html; charset=utf-8");
        request.getRequestURI();
        final String IP = request.getRemoteAddr();
        request.setAttribute("IP", IP);
        System.out.println(IP);
        final String URI=request.getRequestURI();
        request.setAttribute("URI", URI);
        System.out.println(URI);
        arg2.doFilter(arg0, arg1);
    }

    public void init(FilterConfig arg0) throws ServletException {

        // Auto-generated method stub

    }

}

